(function () {
    window.addEventListener('load', function () {
        var telphone = this.document.querySelector("#telphone");
        var regtel = /^[1|3|5|9]\d{10}$/;
        var yzm = this.document.querySelector("#yzm");
        var regyzm = /^\d{6}$/
        regexp(telphone, regtel);
        regexp(yzm, regyzm);
    });

    function regexp(ele, reg) {
        ele.onblur = function () {
            if (reg.test(this.value)) {
                // console.log("success");
                this.nextElementSibling.className = 'success'
                this.nextElementSibling.innerHTML = '输入正确'
            } else {
                // console.log("error");
                this.nextElementSibling.className = 'error'
                this.nextElementSibling.innerHTML = '输入错误'
            }
        }
    }
})();